home *** CD-ROM | disk | FTP | other *** search
- /* MouseTrack.h */
- /*
- *
- * Copyright © 1989 Martin Minow. All rights reserved.
- *
- * You may incorporate portions of this program in your
- * applications without restriction as long as this
- * copyright notice remains intact and the applications
- * are not sold for profit and this source is not
- * redistributed for profit.
- *
- * Private macros and functions are prefixed by _Track_
- */
- #ifndef _MouseTrackHdr_
- #define _MouseTrackHdr_
- #include <ScriptMgr.h>
- /*
- * Compiler-independent datatype definitions.
- */
- typedef short INTEGER;
- typedef unsigned short CHAR;
- typedef long LONGINT;
- typedef unsigned long DOT;
-
- /*
- * All of the information the program needs to process
- * text is contained in the TrackRecord structure.
- * Note that all callback procedures should be declared
- * pascal <type> function.
- */
- typedef struct {
- LONGINT topPixel; /* Top line in viewRect */
- LONGINT leftPixel; /* Leftmost pixel in ViewRect */
- INTEGER lineWidth; /* Document's pixel width */
- Rect viewRect; /* View (clip) rectangle */
- INTEGER lineHeight; /* For line spacing */
- INTEGER fontAscent; /* Caret/highlight position */
- INTEGER fontDescent; /* For caret positioning */
- LONGINT selRow; /* For caret positioning */
- DOT selStart; /* Start of selection range */
- DOT selEnd; /* End of selection range */
- ProcPtr wordBreak; /* At a word boundary? */
- ProcPtr clikLoop; /* Called from TrackClick */
- LONGINT clickTime; /* Mouse-up time */
- DOT clickLoc; /* Mouse-up position */
- LONGINT caretTime; /* Used to flash the caret */
- INTEGER just; /* Justification flags */
- LONGINT textLength; /* Total text length */
- Handle hText; /* Text to be selected */
- INTEGER crOnly; /* If < 0, newline at Return */
- INTEGER txFont; /* Text font number */
- Style txFace; /* Character style */
- INTEGER txMode; /* Pen mode */
- INTEGER txSize; /* Font size */
- GrafPtr inPort; /* Output grafPort */
- INTEGER flags; /* Internal flags */
- ProcPtr highHook; /* User hilite procedure */
- ProcPtr caretHook; /* User draw caret procedure */
- LONGINT refCon; /* For user program use */
- LONGINT nLines; /* Number of lines of text */
- DOT lineStarts[1];/* Start of each line */
- } TrackRecord, *TrackPtr, **TrackHandle;
-
- /*
- * just contains the following values (identical to
- * TextEdit).
- */
- enum {
- trackJustLeft = 0,
- trackJustCenter = 1,
- trackJustRight = -1
- };
-
- /*
- * flags contains the following bit-encoded values.
- */
- #define _Track_has_script_manager 0x0001
- #define _Track_use_script_manager 0x0002
- #define _Track_use_smart_cut_paste 0x0004
- #define _Track_is_active 0x0008
- #define _Track_caret_visible 0x0010
- #define _Track_do_autoscroll 0x0020
-
- /*
- * When any Track routine is called, it calls _Track_lock
- * to record the current state of the TrackRecord in this
- * structure. On exit, _Track_unlock restores the
- * original state.
- */
- typedef struct {
- TrackHandle track_handle; /* The track handle itself */
- INTEGER oldHState; /* Handle locked flag */
- GrafPtr oldPort; /* Caller's GrafPort */
- RgnHandle oldClip; /* Previous clip region */
- INTEGER oldFont; /* Previous font */
- Style oldFace; /* Previous text face */
- INTEGER oldMode; /* Previous drawing mode */
- INTEGER oldSize; /* Previous text size */
- } _Track_state;
-
- /*
- * These macros access the private flags in TrackRecord.
- */
- #define _Track_set(p, x) ((p)->flags |= (x))
- #define _Track_clear(p, x) ((p)->flags &= ~(x))
- #define _Track_flip(p, x) ((p)->flags ^= (x))
- #define _Track_is_set(p, x) (((p)->flags & (x)) != 0)
-
- /*
- * "desired state" parameter for _Track_caret()
- */
- #define _Track_caret_on 0
- #define _Track_caret_off 1
- #define _Track_caret_invert 2
-
- /*
- * This structure records both ends of a word.
- */
- typedef struct {
- DOT start; /* Start of word */
- DOT end; /* End of word */
- } _Track_Loc;
-
- /*
- * User-callable prototypes
- */
- void TrackActivate(TrackHandle);
- void TrackAutoView(Boolean, TrackHandle);
- void TrackCalText(TrackHandle);
- void TrackClick(Point, Boolean, TrackHandle);
- void TrackCopy(TrackHandle);
- void TrackCut(TrackHandle);
- void TrackDeactivate(TrackHandle);
- void TrackDelete(TrackHandle);
- void TrackDispose(TrackHandle);
- OSErr TrackFromScrap(void);
- LONGINT TrackGetHeight(LONGINT, LONGINT, TrackHandle);
- DOT TrackGetOffset(Point, TrackHandle);
- void TrackGetPoint(
- DOT, TrackHandle, LONGINT *, LONGINT *);
- LONGINT TrackGetScrapLen(void);
- #define TrackGetSelectionLength(track_handle) \
- ((*track_handle)->selEnd - (*track_handle)->selStart)
- Handle TrackGetText(TrackHandle);
- void TrackIdle(TrackHandle);
- void TrackInit(void);
- void TrackInsert(Ptr, LONGINT, TrackHandle);
- void TrackKey(CHAR, TrackHandle);
- #define TrackLength(track_handle) \
- ((*track_handle)->textLength)
- TrackHandle TrackNew(INTEGER, Rect *);
- void TrackPaste(TrackHandle);
- void TrackPinScroll(LONGINT, LONGINT, TrackHandle);
- Handle TrackScrapHandle(void);
- void TrackScroll(LONGINT, LONGINT, TrackHandle);
- void TrackSelView(TrackHandle);
- #define TrackSetClikLoop(func, track_handle) \
- ((*track_handle)->clikLoop = func)
- void TrackSetJust(INTEGER, TrackHandle);
- void TrackSetScrapLen(LONGINT);
- void TrackSetSelect(DOT, DOT, TrackHandle);
- void TrackSetText(Ptr, LONGINT, TrackHandle);
- #define TrackSetWordBreak(func, h) \
- ((*track_handle)->wordBreak = func)
- OSErr TrackToScrap(void);
- void TrackUpdate(Rect *, TrackHandle);
-
- /*
- * These functions are called internally by the Track
- * library. They are not be called by user programs.
- * Note: the TrackRecord is locked when these functions
- * are called. A few functions temporarily unlock the
- * TrackRecord: they return a new TrackPtr value.
- */
- void _Track_autoscroll(TrackPtr, Point *);
- void _Track_caret(TrackPtr, INTEGER);
- void _Track_do_clear(TrackHandle, Boolean, Boolean);
- void _Track_do_insert(TrackPtr, long, Ptr, long);
- void _Track_do_paste(TrackHandle);
- void _Track_do_scroll(TrackPtr, LONGINT, LONGINT);
- void _Track_do_update(TrackPtr, Rect *);
- LONGINT _Track_dot_to_bol(TrackPtr, LONGINT);
- LONGINT _Track_dot_to_col(TrackPtr, DOT);
- LONGINT _Track_dot_to_eol(TrackPtr, LONGINT);
- LONGINT _Track_h_origin(TrackPtr, LONGINT);
- void _Track_hilite(TrackPtr, DOT, DOT);
- void _Track_invert_caret(TrackPtr);
- Boolean _Track_is_white(TrackPtr, char *, DOT);
- TrackPtr _Track_lock(TrackHandle, _Track_state *);
- DOT _Track_mouse_to_dot(TrackPtr, Point);
- LONGINT _Track_pixel_row(TrackPtr, INTEGER);
- TrackPtr _Track_rebuild(TrackHandle, DOT);
- LONGINT _Track_row(TrackPtr, DOT);
- LONGINT _Track_row_pixel(TrackPtr, LONGINT);
- void _Track_unlock(_Track_state *);
- void _Track_word(TrackPtr, Point, _Track_Loc *);
-
- /*
- * Track library private data.
- */
- extern Handle TrackScrpHandle; /* Track Scrap */
- extern LONGINT TrackScrpLength; /* Scrap length */
-
- #endif